﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="activeadd.aspx.cs" Inherits="UI.manage.page.active.activeadd" %>
<%@ Import Namespace="Model" %>
<%@ Import Namespace="Common" %>
<div style="margin: 15px;">
	<form class="layui-form" style="padding-left:0px;">
        <div class="layui-form-item">
			<label class="layui-form-label"><font>活动名称</font><em>*</em></label>
			<div class="layui-input-block">
                <input type="text" name="name" placeholder="请输入活动名称" lay-verify="required" autocomplete="off" class="layui-input" value="<%=info.Name %>">
			</div>
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label">活动图片</label>
			<div class="layui-input-inline">
				<div id="upload_products" class='upload_product <%=string.IsNullOrEmpty(info.Img)?"":"hidden" %>'><div id="upload_img"></div></div>
                 <div id="upload_show" class='upload_show <%=string.IsNullOrEmpty(info.Img)?"hidden":"" %>'>
                     <div id="img_container" class="img_container" src="<%=info.Img %>"><img src="<%=info.Img %>"/></div>
                     <div class="reupload"><a href="javascript:Re_Upload()">重传</a></div>
                 </div> <div style="float:left; color:red; padding-top:5px; font-size:12px; padding-left:10px;"></div>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><font>活动内容</font><em>*</em></label>
			<div class="layui-input-block">
                <textarea name="context" class="layui-textarea" placeholder="请输入活动内容" rows="4"><%=info.Context %></textarea>
			</div>
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label"><font>广告链接</font></label>
			<div class="layui-input-block">
				<input type="text" name="link" placeholder="请输入广告链接" autocomplete="off" class="layui-input" value="<%=info.Link %>">
			</div>
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label"><font>联系电话</font></label>
			<div class="layui-input-block">
				<input type="text" name="mobile" placeholder="请输入联系电话" autocomplete="off" class="layui-input" value="<%=info.Mobile %>">
			</div>
		</div>
        <div class='<%=info.ID>0?"hidden":"" %>'>
        <div class="layui-form-item">
			<label class="layui-form-label"><font>红包规则</font></label>
			<div class="layui-input-block">
				<input type="radio" name="moneytype" lay-filter="moneytype" value="1" title="随机红包" <%=info.MoneyType==1?"checked='checked'":"" %> />
                <input type="radio" name="moneytype" lay-filter="moneytype" value="2" title="指定红包" <%=info.MoneyType==2?"checked='checked'":"" %> />
			</div>
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label"><font>红包个数</font><em>*</em></label>
			<div class="layui-input-block">
				<input id="count" type="text" name="count" placeholder="请输入红包个数" autocomplete="off" class="layui-input" value="<%=info.Count %>">
			</div>
		</div>
        <div id="allmoney" class="layui-form-item">
			<label class="layui-form-label"><font>总金额</font><em>*</em></label>
			<div class="layui-input-block">
				<input id="allmoney" type="text" name="allmoney" placeholder="请输入总金额" autocomplete="off" class="layui-input" value="<%=info.AllMoney %>">
			</div>
		</div>
        <div id="onemoney" class="layui-form-item hidden">
			<label class="layui-form-label"><font>单个金额</font><em>*</em></label>
			<div class="layui-input-block">
				<input id="onemoney" type="text" name="onemoney" placeholder="请输入单个金额" autocomplete="off" class="layui-input" value="<%=info.OneMoney %>">
			</div>
		</div>
        </div>
        <div class="layui-form-item">
			<label class="layui-form-label"><font>领奖方式</font><em>*</em></label>
			<div class="layui-input-block">
				<select id="prizetype" name="prizetype" lay-verify="required" lay-filter="prizetype">
					 <option value="1" <%=info.PrizeType==1?"selected":"" %>>无需传播，直接领奖</option>
                     <option value="2" <%=info.PrizeType==2?"selected":"" %>>分享活动详情后领奖</option>
                     <option value="3" <%=info.PrizeType==3?"selected":"" %>>读取语音文字后领奖</option>
				</select>
			</div>
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label"><font>领奖次数</font><em>*</em></label>
			<div class="layui-input-block">
                <input type="text" name="prizecount" placeholder="请输入领奖次数" lay-verify="required" autocomplete="off" class="layui-input" value="<%=info.PrizeCount %>">
			</div>
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label"><font>结束图提醒</font></label>
			<div class="layui-input-block">
				<input type="radio" name="showover" lay-filter="showover" value="0" title="不提醒" <%=info.ShowOver==0?"checked='checked'":"" %> />
                <input type="radio" name="showover" lay-filter="showover" value="1" title="提醒" <%=info.ShowOver==1?"checked='checked'":"" %> />
			</div>
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label"><font>投放范围</font><em>*</em></label>
			<div class="layui-input-block">
				<input type="radio" name="range"  value="1" lay-filter="range" title="全国" <%=info.Range==1?"checked='checked'":"" %> />
                <input type="radio" name="range"  value="2" lay-filter="range" title="选择省" <%=info.Range==2?"checked='checked'":"" %> />
                <input type="radio" name="range"  value="3" lay-filter="range" title="选择市" <%=info.Range==3?"checked='checked'":"" %> />
                <input type="radio" name="range"  value="4" lay-filter="range" title="选择区" <%=info.Range==4?"checked='checked'":"" %> />
			</div>
		</div>
        <div id="selectrange" class="layui-form-item hidden">
			<label class="layui-form-label"><font></font><em></em></label>
			<div class="layui-input-block">
				<div id="province" style="float:left; padding-right:5px;"></div>
                <div id="city" style="float:left;padding-right:5px;"></div>
                <div id="area" style="float:left;"></div>
			</div>
		</div>
		<a lay-filter="save" lay-submit style="display: none;"></a>
	</form>
</div>
<script>
    
    //监听提交
    form.on('radio(range)', function (data) {
        if (data.value == "1") {
            $("#selectrange").hide();
        }
        if (data.value == "2") {
            $("#selectrange,#province").show();
            $("#city,#area").html("");
            Init_Province("<%=info.Province %>");

        }
        if (data.value == "3") {
            $("#selectrange,#province,#city").show();
            $("#area").html("");
            Init_Province("<%=info.Province %>");
            Init_City("<%=info.City %>");
        }
        if (data.value == "4") {
            $("#selectrange,#province,#city,#area").show();
            Init_Province("<%=info.Province %>");
            Init_City("<%=info.City %>");
            Init_Area("<%=info.Area %>");
        }
    });
    form.on('radio(moneytype)', function (data) {
        if (data.value == "1") {
            $("#onemoney").hide();
            $("#allmoney").show();
        } else {
            $("#onemoney").show();
            $("#allmoney").hide();
        }
    });
    function Init_Province(province) {
        var str = '<select name="province" lay-verify="required" lay-filter="province">'
        $.each($.rawCitiesData, function (i, info) {
            str += '<option value="' + info.name + '" ' + (info.name == province ? "selected" : "") + '>' + info.name + '</option>';
        });
        str += '</select>';
        $("#province").html(str);
        form.render("select");
        form.on('select(province)', function (data) {
            Init_City(data.value);
            Init_Area($("#city").val());
        });
    };
    function Init_City(city) {
        var province = $("#province select").val();
        var str = '<select id="city" name="city" lay-verify="required" lay-filter="city">'
        $.each($.rawCitiesData, function (i, info) {
            if (info.name == province) {
                
                $.each(info.sub, function (k, info2) {
                    str += '<option value="' + info2.name + '" ' + (info2.name == city ? "selected" : "") + '>' + info2.name + '</option>';
                });
            }
        });
        str += '</select>';
        $("#city").html(str);
        form.render("select");
        form.on('select(city)', function (data) {
            Init_Area(data.value);
        });
    };
    function Init_Area(area) {
        var province = $("#province select").val();
        var city = $("#city select").val();
        var str = '<select name="area" lay-verify="required" lay-filter="area">'
        $.each($.rawCitiesData, function (i, info) {
            if (info.name == province) {
                $.each(info.sub, function (k, info2) {
                    if (info2.name == city) {
                        $.each(info2.sub, function (k, info3) {
                            str += '<option value="' + info3.name + '" ' + (info3.name == area ? "selected" : "") + '>' + info3.name + '</option>';
                        });
                    }
                });
            }
        });
        str += '</select>';
        $("#area").html(str);
        form.render("select");
    };
    var range = "<%=info.Range %>";
    if (range == "2") {
        $("#selectrange,#province").show();
        $("#city,#area").html("");
        Init_Province("<%=info.Province %>");

    }
    if (range == "3") {
        $("#selectrange,#province,#city").show();
        $("#area").html("");
        Init_Province("<%=info.Province %>");
        Init_City("<%=info.City %>");
    }
    if (range == "4") {
        $("#selectrange,#province,#city,#area").show();
        Init_Province("<%=info.Province %>");
        Init_City("<%=info.City %>");
        Init_Area("<%=info.Area %>");
    }
</script>